package messages.udp;

import messages.BaseMessage;
import messages.MessageType;
import messages.MessageUtils;

public class PersonTransferMessage extends BaseMessage {

    public static final byte GOING_IN = 1;
    public static final byte GOING_OUT = 0;
    
	private int weight;
	private byte inOut;
	
    public PersonTransferMessage(byte[] data)
    {
        super(data);
        this.inOut = data[1];
        this.weight = MessageUtils.parseInt(data,2);
    }

    public PersonTransferMessage(byte inOut,int weight){
    	super(null);
    	this.inOut=inOut;
    	this.weight=weight;
    }
    
    @Override
    public byte[] toByteArray()
    {
        byte[] retVal = new byte[getMessageSize()];
        retVal[0] = getMessageType().getIdentifier();
        retVal[1] = inOut;
        MessageUtils.insertInt(retVal, 2, weight);
        return retVal;
    }

    @Override
    public MessageType getMessageType()
    {
        return MessageType.PersonTransferMessage;
    }

    @Override
    public int getMessageSize()
    {
        return 6;
    }

}
